<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateCustomerCouponShopMappingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_coupon_shop_mappings', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('customerCouponId')->default(0)->comment('用户优惠券id');
            $table->unsignedBigInteger('shopId')->default(0)->comment('店铺id');
            $table->index('customerCouponId','idx_customerCouponId');
            $table->tinyInteger("status")->default(0)->comment("状态,0:正常,1:停用,2:其他");
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->index('shopId','idx_shopId');
        });

        $prefix = config('other.DB_PREFIX', '');
        DB::statement("ALTER TABLE `{$prefix}customer_coupon_shop_mappings` COMMENT = '用户优惠券表店铺关联表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_coupon_shop_mappings');
    }
}
